package org.example.cloud.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.cloud.api.PayFeignSentinelApi;
import org.example.cloud.util.ResultData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author 宋孟林
 * @description
 * @date: 2025/4/10 9:36
 */
@RestController
@Slf4j
@ConfigurationProperties
public class OrderNacosController {
    @Resource
    private RestTemplate restTemplate;

    @Resource
    private PayFeignSentinelApi payFeignSentinelApi;
    @Value("${service-url.nacos-user-service}")
    private String serverURL;
    @GetMapping("consumer/pay/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Integer id){
        String result = restTemplate.getForObject(serverURL + "/pay/nacos/" + id, String.class);
        return result + "\t" + "我是微服务的调用者.............";
    }

    @GetMapping(value = "/consumer/pay/nacos/get/{orderNo}")
    public ResultData<?> getPayByOrderNo(@PathVariable("orderNo") String orderNo) {
        return payFeignSentinelApi.getPayByOrderNo(orderNo);
    }

}

